<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/meta.jsp"%>
<title>电梯信息管理</title>
</head>
<body>
	<%@include file="/common/header.jsp" %>
	<table cellpadding="0" cellspacing="0" border="0" align="center" width="640" style="margin: 10px auto;font-size: 14px;">
		<tr>
			<td width="120" height="40" align="right">
				<label>电梯类别:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="tslbName" readonly="readonly" onclick="showTslb(this)" />
				<input id="tslbId" type="hidden" />
			</td>
			<td width="120" height="40" align="right">
				<label>注册代码:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="dtxxZcdm" />
			</td>
		</tr>
		<tr>
			<td width="120" height="40" align="right">
				<label>使用单位:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="dtxxSydwName" />
			</td>
			<td width="120" height="40" align="right">
				<label>维保单位:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="dtxxWbdwName" />
			</td>
		</tr>
		<tr>
			<td width="120" height="40" align="right">
				<label>出厂编号:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="dtxxCcbh" />
			</td>
			<td width="120" height="40" align="right">
				<label>维保责任人:</label>
			</td>
			<td align="left" height="40" width="200">
				<input id="dtxxWbzrr" />
			</td>
		</tr>
		<tr>
			<td colspan="4" align="center" height="40">
				<input id="btn_cx" type="button" value="查询" style="background: #06a0ef; border: medium none; color: #fff; height: 30px; margin-left: 20px; outline: medium none; width: 100px;"/>
	    		<input id="btn_czh" type="button" value="重置" style="background: #06a0ef; border: medium none; color: #fff; height: 30px; margin-left: 20px; outline: medium none; width: 100px;"/>
	    	</td>
		</tr>
	</table>
	<div id="dtxxGrid"></div>
	
	<script type="text/javascript">
	$(function(){
		$("#dtxxGrid").flexigrid({
			title:"电梯信息信息",
			url:'<c:url value='/ssjk/dataGrid'/>',
			colModel:[
				{display: "设备注册代码", name: "dtxxZcdm"},
				{display: "电梯名称", name: "dtxxSbmc"},
				{display: "电梯类别", name: "dtxxTslbname"},
				{display: "使用单位", name: "dtxxSydwName"},
				{display: "维保单位", name: "dtxxWbdwName"},
				{display: "所在地址", name: "dtxxSydz"}
			],
			buttons:[
				{name: "新增", bimage: "<c:url value='/common/js/flexigrid/css/images/add.png'/>", onpress: btns},
				{separator: true},
				{name: "修改", bimage: "<c:url value='/common/js/flexigrid/css/images/modify.png'/>", onpress: btns},          
				{separator: true},
				{name: "删除", bimage: "<c:url value='/common/js/flexigrid/css/images/delete.png'/>", onpress: btns},
				{separator: true}
			],
			usepager: true
		});
		
		//查询
		$("#btn_cx").click(function() {
			$("#dtxxGrid").flexOptions({
				newp : 1,
				params : [ 
				           {name : 'dtxxTslbid', value : $("#tslbId").val()},
				           {name : 'dtxxZcdm', value : $("#dtxxZcdm").val()},
				           {name : 'dtxxSydwName', value : $("#dtxxSydwName").val()},
				           {name : 'dtxxWbdwName', value : $("#dtxxWbdwName").val()},
				           {name : 'dtxxCcbh', value : $("#dtxxCcbh").val()},
				           {name : 'dtxxWbzrr', value : $("#dtxxWbzrr").val()}
						]
			}).flexReload();
		});
		
		//重置
		$("#btn_czh").click(function() {
			$("#tslbName").val("");
			$("#tslbId").val("");
			$("#dtxxZcdm").val("");
			$("#dtxxSydwName").val("");
			$("#dtxxWbdwName").val("");
			$("#dtxxCcbh").val("");
			$("#dtxxWbzrr").val("");
		});
		
	});
	
	function btns(com,grid){
		if("新增" == com) {
			art.dialog.open(
					"<c:url value='/ssjk/fDtxx'/>",
					{
						id: "addDtxx",
						title: "添加电梯信息",
						lock: true,
						width: 700,
						height: 400
					}
				);
		}else if($(".trSelected", grid).length == 1) {
			var id=$('.trSelected', grid).attr("id").replace("row","");
			if("修改" == com) {
				art.dialog.open(
					"<c:url value='/ssjk/toUpdate?dtxxId="+id+"'/>",
					{
						id: "updateDtxx",
						title: "修改电梯信息",
						lock: true,
						width: 700,
						height: 400
					}
				);
			}else if("删除" == com) {
				$.post("<c:url value='/ssjk/deleteDtxx'/>", 
					{ "dtxxId": id}, 
					function(json){
						if(json.flag==1){
							$("#dtxxGrid").flexReload();
							art.dialog.alert("电梯信息删除成功。");
						}else{
							art.dialog.alert("电梯信息删除失败。");
						}
				});
			}
		}else {
			art.dialog.alert("请选择要" + com + "的电梯！");
		}
	}
	
	//关闭弹出
	function closeAndRefresh(){
		$("#dtxxGrid").flexReload();
		$.each(art.dialog.list, function(i, n) {
			art.dialog.list[i].close();
		});
	}
	</script>
	<script type="text/javascript" src="<c:url value="/common/js/zd/tslb.js"/>" ></script>
</body>
</html>